<?php

/**
 * constancias actions.
 *
 * @package    atenea
 * @subpackage constancias
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class constanciasActions extends sfActions
{
 
 public function executeIndex()
  {
    return $this->forward('constancias', 'create');
  }

// Funcion para busacr los datos del estudiante y personal del Dept de Orientacion
 public function executeDatos()
	{

	  if ($this->getRequestParameter('ajax')=='1')
	    {
	    	$this->rol = $this->getRequestParameter('rol');
	    	if ($this->getRequestParameter('rol')=='1' or $this->getRequestParameter('rol')=='2'
	    	 or $this->getRequestParameter('rol')=='3' or $this->getRequestParameter('rol')=='4')
	    	{
			    $objDatopersonal = new DatoPersonal();
	    		$this->ced = $this->getRequestParameter('cedula');
	    		$objDP = $objDatopersonal->getObjDatoPersonalConCedula($this->ced);
	    		$this->profesor = $objDP;
	    		   if ($objDP == null)
         			{
         				$this->setFlash('notice', 'Esta cedula no le pertenece a un profesor');
         			}
         			else
         			{
						$objUsu = $objDP->getObjAteneaUsuarioConCed();
						$this->usuario = $objUsu;
						$this->getUser()->setAttribute('idSol', $objUsu->getId());

         			}
	    	    }
	    	else{
	    	   $objEstudiante = new Estudiante();
         	   $this->ced = $this->getRequestParameter('cedula');
         	   $datos = $objEstudiante->getDatosDelEstudianteConCed($this->ced);
         	   $this->estudiante =$datos;
         			if ($datos == null)
         			  {
         				$this->setFlash('notice', 'Esta cedula no le pertenece a un estudiante');
         			  }
         			else
         			  {
						$objUsu = $datos->getObjAteneaUsuarioConCed();
						$this->usuario = $objUsu;
						$this->getUser()->setAttribute('idSol', $objUsu->getId());

         			  }
	            }
	    }
   }


  public function executeList()
  {
    $this->processSort();

    $this->processFilters();


    // pager
    $this->pager = new sfPropelPager('Ateneausuario', 20);
    $c = new Criteria();
    $this->addSortCriteria($c);
    $this->addFiltersCriteria($c);
    $this->pager->setCriteria($c);
    $this->pager->setPage($this->getRequestParameter('page', 1));
    $this->pager->init();
  }

  public function executeCreate()
  {
    return $this->forward('constancias', 'edit');
  }


  public function handleErrorEdit()
  {
    $this->preExecute();
    $this->ateneausuario = $this->getAteneausuarioOrCreate();
    $this->updateAteneausuarioFromRequest();

    $this->labels = $this->getLabels();

    return sfView::SUCCESS;
  }

  protected function processFilters()
  {
  }
  protected function addFiltersCriteria($c)
  {
  }
  
}
